/*****************************************************************************
* File Name: trackpad_custom_gesture.h
*
* Version: 1.0
*
* Description:
* This file contains functions and macros for custom gesture detection module 
*
* Note:
* Define DISABLE_TRACKPAD in platform.h to disable trackpad module
*
* Owner: SKUV
*
* Related Document:
* CapSense Gesture data sheet
*
* Hardware Dependency:
* Trackpad PCB
*
* Code Tested With:
* 1. PSoC Creator 3.1 
* 2. ARM GCC 4.8.4
******************************************************************************
* Copyright (2015), Cypress Semiconductor Corporation.
******************************************************************************
* This software is owned by Cypress Semiconductor Corporation (Cypress) and is
* protected by and subject to worldwide patent protection (United States and
* foreign), United States copyright laws and international treaty provisions.
* Cypress hereby grants to licensee a personal, non-exclusive, non-transferable
* license to copy, use, modify, create derivative works of, and compile the
* Cypress Source Code and derivative works for the sole purpose of creating
* custom software in support of licensee product to be used only in conjunction
* with a Cypress integrated circuit as specified in the applicable agreement.
* Any reproduction, modification, translation, compilation, or representation of
* this software except as specified above is prohibited without the express
* written permission of Cypress.
*
* Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH
* REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 
* Cypress reserves the right to make changes without further notice to the
* materials described herein. Cypress does not assume any liability arising out
* of the application or use of any product or circuit described herein. Cypress
* does not authorize its products for use as critical components in life-support
* systems where a malfunction or failure may reasonably be expected to result in
* significant injury to the user. The inclusion of Cypress' product in a life-
* support systems application implies that the manufacturer assumes all risk of
* such use and in doing so indemnifies Cypress against all charges. Use may be
* limited by and subject to the applicable Cypress software license agreement.
*****************************************************************************/
#ifndef _TRACKPAD_CUSTOM_GESTURE_H_
#define _TRACKPAD_CUSTOM_GESTURE_H_

#include "trackpad.h"
#include "trackpad_scroll_gesture.h"
#include "trackpad_ballasitic.h"

#define SCROLL_XRESOLUTION_MARGIN            (100u)
#define SCROLL_YRESOLUTION_MARGIN            (100u)

#define TRACKPAD_XRESOLUTION                 (400u)
#define TRACKPAD_YRESOLUTION                 (400u)

#define SCROLL_HORIZONTAL_START_BOUNDARY     ((uint16)(TRACKPAD_XRESOLUTION - SCROLL_XRESOLUTION_MARGIN))
#define SCROLL_HORIZONTAL_STOP_BOUNDARY      ((uint16)(TRACKPAD_XRESOLUTION))
#define SCROLL_HORIZONTAL_DISTANCE           (50u)
#define SCROLL_HORIZONTAL_TIME_THRESHOLD     (100u)

#define SCROLL_VERTICAL_START_BOUNDARY        ((uint16)(TRACKPAD_YRESOLUTION - SCROLL_YRESOLUTION_MARGIN))
#define SCROLL_VERTICAL_STOP_BOUNDARY         ((uint16)(TRACKPAD_YRESOLUTION))
#define SCROLL_VERTICAL_DISTANCE              (50u)
#define SCROLL_VERTICAL_TIME_THRESHOLD        (100u)

#define BALLASITIC_FILTER_ACCELERATION        (7u)
#define BALLASITIC_FILTER_SPEED_LEVEL         (4u)
#define BALLASITIC_FILTER_DIVISOR_VALUE       (4u)
#define BALLASITIC_FILTER_THRESHOLD_X         (2u)
#define BALLASITIC_FILTER_THRESHOLD_Y         (2u)

#define EDGE_SWIPE_BOUNDARY                   (50u)
#define EDGE_SWIPE_TIMEOUT                    (1000u)
#define EDGE_SWIPE_DETECTED_TIMEOUT           (1000u)
#define EDGE_SWIPE_ACTIVATION_THRESHOLD       (70u)
    
#define ZOOM_IN_COUNT_THRESHOLD               (4u)
#define ZOOM_OUT_COUNT_THRESHOLD              (4u)

#define CLICK_DETECTION_TIMEOUT               (CSD_Touchpad_gesturesConfig.STClickTimeoutMax)
#define CLICK_X_RADIUS                        (CSD_Touchpad_gesturesConfig.clickRadiusX)
#define CLICK_Y_RADIUS                        (CSD_Touchpad_gesturesConfig.clickRadiusY)

#define EDGE_SWIPE_TOP                        (0xAA) /* Code for Top to bottom swipe gesture */
#define EDGE_VERTICAL_SCROLL_NORTH            (0xAB) /* Code for vertical scroll north gesture */
#define EDGE_VERTICAL_SCROLL_SOUTH            (0xAC) /* Code for vertical scroll south gesture */
#define EDGE_HORIZONTAL_SCROLL_EAST           (0xAD) /* Code for horizontal scroll east gesture */
#define EDGE_HORIZONTAL_SCROLL_WEST           (0xAE) /* Code forhorizontal scroll west gesture */
#define DUMMY_GESTURE                         (0xFF) /* Code not to send the any keycode */

#define DIFF_POINTER_MOVEMENT

#define Trackpad_Custom_Scroll_Count()         Trackpad_Scroll_Get_ScrollCount()

/*****************************************************************************
* Function Name: Trackpad_Custom_PointerMovement_Calulation()
******************************************************************************
* Summary:
* This function calculates pointer movement and returns report type
*
* Parameters:
* Report *report - Pointer for report structure
* bool *is_pointer_movement - Pointer for is_pointer_movement variable
*
* Return:
* None
*
* Note:
* None
*****************************************************************************/
extern ReportType Trackpad_Custom_PointerMovement_Calulation(Report *report, bool *is_pointer_movement);

/*****************************************************************************
* Function Name: Trackpad_Custom_Gesture_Init()
******************************************************************************
* Summary:
* This function initialises various parameters for the that is required for the 
* custom gestures
*
* Parameters:
* None
*
* Return:
* None
*
*****************************************************************************/
extern void Trackpad_Custom_PointerMovement_Reset(void);

#endif /* _TRACKPAD_CUSTOM_GESTURE_H_ */
